home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wmv12s.zip / FUNC32H.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  2KB  |  67 lines

  1. ; Call DOS 32H from C. This is an undocumented function call documented in
  2. ; PC Tech. Journal May 1986. This function returns a pointer to a disk
  3. ; description table that contains the following:
  4. ;
  5. ;   offset  length  what
  6. ;   ------  ------  ----
  7. ;      0     byte   assigned physical disk (A=0, B=1, ...)
  8. ;      1     byte   same as above but 0 for RAM disk
  9. ;      2     word   bytes per sector
  10. ;      4     byte   sectors per cluster minus 1
  11. ;      5     byte   #heads minus 1
  12. ;      6     word   reserved sectors
  13. ;      8     byte   #copies of FAT (normally 2 for real disks, 1 for RAM disks)
  14. ;      9     word   max directory entries
  15. ;     11     word   first usable sector (i.e. data area)
  16. ;     13     word   total cluster count plus 1
  17. ;     15     byte   #sectors occupied by each FAT
  18. ;     16     word   first sector of the root's directory
  19. ;     18    dword   device driver address
  20. ;     22     word   media descriptor
  21. ;     24    dword   chain to next disk table
  22. ;     28     word   cluster of current working directory
  23. ;
  24. ; in C, use
  25. ;   unsigned char drv,    /* drive number: 1=A, 2=B, ...; 0=current drive */
  26. ;          status;  /* if 0xFF means invalid drive */
  27. ;   unsigned short tabseg,  /* disk description table segment */
  28. ;           taboff;  /* disk description table offset */
  29. ;
  30. ;   status = func32h(drv, &tabseg, &taboff);
  31. ;
  32. ; The reason for writing this procedure in assembly is because the
  33. ; function returns the description table segment address in DS which
  34. ; cannot be accessed by using intdosx() function in C.
  35. ;
  36. ; Written by Peter Wu 6/27/86
  37. ;
  38. _text    segment public byte 'code'
  39.     assume cs:_text
  40.  
  41.     public    _func32h
  42. _func32h proc     near
  43.     push    bp
  44.     mov    bp,sp
  45.     push    ds        ; save DS
  46.  
  47.     mov    dl,[bp+4]    ; drive number
  48.     mov    ah,32h
  49.     int    21h
  50.  
  51.     mov    cx,bx        ; stupid move, but I need bx
  52.     mov    si,ds
  53.     pop    ds
  54.  
  55.     mov    bx,[bp+6]    ; &tabseg
  56.     mov    [bx],si     ; store tabseg
  57.     mov    bx,[bp+8]    ; &taboff
  58.     mov    [bx],cx     ; store taboff
  59.     mov    ah,0        ; al contains ffh if error
  60.  
  61.     pop    bp
  62.     ret
  63. _func32h endp
  64.  
  65. _text    ends
  66.     end
  67.